home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK2.toast / Development Kits (Disc 2) / QuickDraw GX / Programming Stuff / Sample Code / Typography Samples / Dave’s Fab Samples ƒ / Continuous Justification.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-04-10  |  2.3 KB  |  98 lines  |  [TEXT/KAHL]

  1. #include <Types.h>
  2. #include <QuickDraw.h>
  3. #include <Fonts.h>
  4. #include <Windows.h>
  5. #include <Menus.h>
  6. #include <SegLoad.h>
  7. #include <Memory.h>
  8. #include <Desk.h>
  9.  
  10. #include "graphics routines.h"
  11. #include "graphics libraries.h"
  12. #include "graphics toolbox.h"
  13.  
  14. #include "layout types.h"
  15. #include "layout routines.h"
  16. #include "layout library.h"
  17.  
  18. #include "SampleInterface.h"
  19.  
  20. short MyStrLen(char *x);
  21. static short MyStrLen(x)
  22. char    *x;
  23.     {
  24.     short c = 0;
  25.     while (*x++) c++;
  26.     return c;
  27.     }    /* MyStrLen */
  28.  
  29. void ContinuousJustification(WindowPtr sampleWindow)
  30.     {
  31.     /* Variables */
  32.     char            *myString = "A line of text";
  33.     gxLayoutOptions    gxLayoutOptions;
  34.     gxLine            myLine;
  35.     gxPoint            myPoint;
  36.     gxRunControls        gxRunControls;
  37.     gxShape            layout;
  38.     short            len, level = 0;
  39.     gxStyle            myStyle;
  40.     gxViewPort        aViewPort;
  41.     
  42.     /* Initialization */
  43.     
  44.     myPoint.x = ff(30);
  45.     myPoint.y = ff(50);
  46.  
  47.     aViewPort = GXNewWindowViewPort(sampleWindow);
  48.     SetDefaultViewPort(aViewPort);
  49.     
  50.     len = MyStrLen(myString);
  51.     InitializeRunControls(&gxRunControls);
  52.     
  53.     InitializeLayoutOptions(&gxLayoutOptions);
  54.     gxLayoutOptions.width = ff(500);
  55.     gxLayoutOptions.just = 0;
  56.     
  57.     myLine.first.x = myLine.last.x = myPoint.x;
  58.     myLine.first.y = 0;
  59.     myLine.last.y = ff(1000);
  60.     GXDrawLine(&myLine);
  61.     
  62.     myLine.first.x = myLine.last.x = myPoint.x + gxLayoutOptions.width;
  63.     GXDrawLine(&myLine);
  64.     
  65.     myStyle = NewLayoutStyle((char *) "\pHoefler Text", ff(50), 0, nil, nil, 0, nil);
  66.     
  67.     layout = GXNewLayout(
  68.         1, &len, (void *) &myString,
  69.         1, &len, &myStyle,
  70.         1, &len, &level,
  71.         nil, &myPoint);
  72.     GXDrawShape(layout);
  73.     
  74.     gxLayoutOptions.just = fract1 / 4;
  75.     GXSetLayout(layout, 0, nil, nil, 0, nil, nil, 0, nil, nil, &gxLayoutOptions, nil);
  76.     GXMoveShape(layout, 0, ff(75));
  77.     GXDrawShape(layout);
  78.     
  79.     gxLayoutOptions.just = fract1 / 2;
  80.     GXSetLayout(layout, 0, nil, nil, 0, nil, nil, 0, nil, nil, &gxLayoutOptions, nil);
  81.     GXMoveShape(layout, 0, ff(75));
  82.     GXDrawShape(layout);
  83.     
  84.     gxLayoutOptions.just = 3 * (fract1 / 4);
  85.     GXSetLayout(layout, 0, nil, nil, 0, nil, nil, 0, nil, nil, &gxLayoutOptions, nil);
  86.     GXMoveShape(layout, 0, ff(75));
  87.     GXDrawShape(layout);
  88.     
  89.     gxLayoutOptions.just = fract1;
  90.     GXSetLayout(layout, 0, nil, nil, 0, nil, nil, 0, nil, nil, &gxLayoutOptions, nil);
  91.     GXMoveShape(layout, 0, ff(75));
  92.     GXDrawShape(layout);
  93.     
  94.     GXDisposeShape(layout);
  95.     GXDisposeStyle(myStyle);
  96.     GXDisposeViewPort(aViewPort);
  97.     }    /* main */
  98.